package cn.hz.pi.api.inteface;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


public class PIDate {
	private int year;
	private int month;
	private int day;
	private int hour;
	private int minutes;
	private int seconds;

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public int getHour() {
		return hour;
	}

	public void setHour(int hour) {
		this.hour = hour;
	}

	public int getMinutes() {

		return minutes;
	}

	public void setMinutes(int minutes) {

		this.minutes = minutes;

	}

	public int getSeconds() {

		return seconds;
	}

	public void setSeconds(int seconds) {

		this.seconds = seconds;
	}

	public static PIDate getPIDate(String time){ 
		Date dateFormat;
		PIDate date = new PIDate();
		Calendar cal=Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
		try {
			dateFormat = sdf.parse(time);
			cal.setTime(dateFormat);
			date.setYear(cal.get(Calendar.YEAR)); 
			date.setMonth(cal.get(Calendar.MONTH)+1); 
			date.setDay(cal.get(Calendar.DATE)); 
			date.setHour(cal.get(Calendar.HOUR_OF_DAY)); 
			date.setMinutes(cal.get(Calendar.MINUTE)); 
			date.setSeconds(cal.get(Calendar.SECOND)); 
		} catch (ParseException e) {
			e.printStackTrace();
		}  
		
		return date; 
	}
}
